//
//  ViewController.m
//  05-UIScrollView
//
//  Created by dllo on 16/7/20.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#define kScreenBounds [UIScreen mainScreen].bounds//洪就是替换(预编译指令)
#define WIDTH kScreenBounds.size.width//宏定义 命名两种方式 全大写 全小写
#define HEIGHT kScreenBounds.size.height
@interface ViewController ()<UIScrollViewDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    UIScrollView *scrollView = [[UIScrollView alloc] init];
    scrollView.frame = kScreenBounds;
    scrollView.backgroundColor = [UIColor redColor];
//    scrollView.contentSize = CGSizeMake(WIDTH * 7, 0);//设置可以滚动的范围
    [self.view addSubview:scrollView];
//    1.
//    改变contentOffset的
    NSLog(@"%@",NSStringFromCGRect(scrollView.frame));
     NSLog(@"%@",NSStringFromCGRect(scrollView.bounds));
    scrollView.contentOffset = CGPointMake(1000, 1000);//偏移量，滚动的位置
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(10, 10, WIDTH - 20, 100);
    button.backgroundColor = [UIColor blueColor];
    [scrollView addSubview:button];
    scrollView.contentInset = UIEdgeInsetsMake(10, 10, 10, 10);//添加滚动区域四周的滚动范围
//    锁定垂直或水平滚动（45度角，锁会失效）
    scrollView.directionalLockEnabled = YES;//锁定垂直或水平滚动
//边缘弹动动画关闭 NO
    scrollView.bounces = YES;//回弹效果
    scrollView.alwaysBounceVertical = YES;//在没有垂直方向的滚动范围时，保证垂直方向的回弹效果存在
    scrollView.alwaysBounceHorizontal = YES;//在没有水平方向的滚动范围，保证水平方向的回弹效果
    
//    UIPageControl *pageControl = [[UIPageControl alloc] init];
//    pageControl.frame = CGRectMake(20, 20, 100, 30);
//    pageControl.backgroundColor = [UIColor greenColor];
//    [self.view addSubview:pageControl];
//    pageControl.numberOfPages = 3;
    
    scrollView.pagingEnabled = YES;//翻页滚动
    scrollView.scrollEnabled = YES;//滚动试图能否滚动，默认yes
    scrollView.showsHorizontalScrollIndicator = NO;//是否显示垂直/水平的显示器，默认yes
    scrollView.showsVerticalScrollIndicator = NO;
    scrollView.scrollIndicatorInsets = UIEdgeInsetsMake(100, 0, 0, 0);//滚动指示器的边距
    scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;//滚动指示器的颜色（深色，浅色，通用）
//    用户相关操作
//    scrollView.tracking 用户有没有拖动
//    scrollView.dragging  用户是否拖动中
//    scrollView.decelerating 是否开始减速
    
    scrollView.scrollsToTop = YES;//滚动视图双击状态栏手势是否存在 默认yes
    scrollView.delegate = self;
    
    
    
    
    
    
    
    
    
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
